package org.zpmis.api.http;

import org.springframework.validation.annotation.Validated;
import org.zpmis.api.business.IntentionWebService;
import org.zpmis.common.base.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.zpmis.common.result.PlatformResult;
import org.zpmis.common.result.ResultCode;
import org.zpmis.domain.customer.qo.AddIntentionQo;
import org.zpmis.domain.customer.qo.IntentionListQo;
import org.zpmis.domain.customer.qo.IntentionTrackQo;

import javax.annotation.Resource;

/**
* created with CodeGenerator
* description: 意向客户控制入口
* @author  Yang
* date: 2021-6-2
* time: 14:48:50
*/
@RestController
@RequestMapping("/intention")
@Slf4j
public class IntentionController extends BaseController{

    @Resource
    private IntentionWebService intentionWebService;


    /**
     *  新增意向客户
     * @param addIntentionQo
     * @return
     */
    @PostMapping("/addIntention")
    public PlatformResult addIntention(@Validated @RequestBody AddIntentionQo addIntentionQo){
        try {
            intentionWebService.addIntention(addIntentionQo);
        } catch (Exception e) {
            log.error("[IntentionController]---addIntention--->Exception:",e);
            return PlatformResult.failure();
        }
        return PlatformResult.success();
    }


    /**
     *  意向用户列表查询
     * @param intentionListQo
     * @return
     */
    @PostMapping("/intentionList")
    public PlatformResult intentionList(@RequestBody IntentionListQo intentionListQo){
        try {
            return PlatformResult.success(intentionWebService.intentionList(intentionListQo));
        } catch (Exception e) {
            log.error("[IntentionController]---intentionList--->Exception:",e);
            return PlatformResult.failure();
        }
    }


    /**
     *  意向轨迹查询
     * @param intentionTrackQo
     * @return
     */
    @PostMapping("/intentionTrack")
    public PlatformResult intentionTrack(@RequestBody IntentionTrackQo intentionTrackQo){
        try {
            return PlatformResult.success(intentionWebService.intentionTrack(intentionTrackQo));
        } catch (Exception e) {
            log.error("[IntentionController]---intentionTrack--->Exception:",e);
            return PlatformResult.failure();
        }
    }
}
